﻿using System;
using System.Collections;
using System.Data;
using DotNetNuke.Framework;
using System.Web.UI.HtmlControls;
using gdlmo.DNN.Modules.ImgNews.Data;
using gdlmo.DNN.Modules.Article.Business;

namespace gdlmo.DNN.Modules.ImgNews.Business
{
	public class ImgNewsController : DotNetNuke.Entities.Modules.ISearchable, DotNetNuke.Entities.Modules.IPortable
	{
		#region "Public Methods"		
		public ImgNewsInfo Get(int ImgNewsId,int moduleId )
		{
			return (ImgNewsInfo)DotNetNuke.Common.Utilities.CBO.FillObject(DataProvider.Instance().GetImgNews(ImgNewsId,moduleId), typeof(ImgNewsInfo));
		}

		public ArrayList List()
		{
			return DotNetNuke.Common.Utilities.CBO.FillCollection(DataProvider.Instance().ListImgNews(), typeof(ImgNewsInfo));
		}
		public ArrayList List(int moduleId)
		{
			return DotNetNuke.Common.Utilities.CBO.FillCollection(DataProvider.Instance().ListImgNews(moduleId), typeof(ImgNewsInfo));
		}
	
		public int Add(ImgNewsInfo objImgNews)
		{
			return (int)DataProvider.Instance().AddImgNews(objImgNews.ModuleId, objImgNews.Title, objImgNews.ImgLink, objImgNews.Links, objImgNews.Target, objImgNews.IP, objImgNews.CreateByUser, objImgNews.Author, objImgNews.IsActive, objImgNews.CreateDate);
		}

		public int Add(ImgNewsInfo objImgNews,HtmlInputFile fileinput)
		{
			string filename = Article.gdlmoGlobal.GetFileName(fileinput);
			Article.gdlmoGlobal.SaveFile("ImgNews",filename,fileinput);
			return (int)DataProvider.Instance().AddImgNews(objImgNews.ModuleId, objImgNews.Title, objImgNews.ImgLink, objImgNews.Links, objImgNews.Target, objImgNews.IP, objImgNews.CreateByUser, objImgNews.Author, objImgNews.IsActive, objImgNews.CreateDate);
		}	
		public void Update(ImgNewsInfo objImgNews)
		{
			DataProvider.Instance().UpdateImgNews(objImgNews.ImgNewsId, objImgNews.ModuleId, objImgNews.Title, objImgNews.ImgLink, objImgNews.Links, objImgNews.Target, objImgNews.IP, objImgNews.CreateByUser, objImgNews.Author, objImgNews.IsActive, objImgNews.CreateDate);
		}

		public void Update(ImgNewsInfo objImgNews,HtmlInputFile fileinput)
		{
			string filename = Article.gdlmoGlobal.GetFileName(fileinput);
			Article.gdlmoGlobal.SaveFile("ImgNews",filename,fileinput);
			DataProvider.Instance().UpdateImgNews(objImgNews.ImgNewsId, objImgNews.ModuleId, objImgNews.Title, objImgNews.ImgLink, objImgNews.Links, objImgNews.Target, objImgNews.IP, objImgNews.CreateByUser, objImgNews.Author, objImgNews.IsActive, objImgNews.CreateDate);
		}
		
		public void Delete(int ImgNewsId)
		{
			DataProvider.Instance().DeleteImgNews(ImgNewsId);
		}
		#endregion

		#region "Optional Interfaces"		
		public DotNetNuke.Services.Search.SearchItemInfoCollection GetSearchItems(DotNetNuke.Entities.Modules.ModuleInfo ModInfo)
		{
			return null;
		}
	
		public string ExportModule(int ModuleID)
		{
			return "";
		}

		public void ImportModule(int ModuleID, string Content, string Version, int UserId)
		{
		}
		#endregion
	}
}
